/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pojos;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author A7med Kotb
 */
@Entity
@Table(name = "employees")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Employees.findAll", query = "SELECT e FROM Employees e"),
    @NamedQuery(name = "Employees.findByEmpId", query = "SELECT e FROM Employees e WHERE e.empId = :empId"),
    @NamedQuery(name = "Employees.findByFirstName", query = "SELECT e FROM Employees e WHERE e.firstName = :firstName"),
    @NamedQuery(name = "Employees.findByLastName", query = "SELECT e FROM Employees e WHERE e.lastName = :lastName"),
    @NamedQuery(name = "Employees.findByPassword", query = "SELECT e FROM Employees e WHERE e.password = :password"),
    @NamedQuery(name = "Employees.findByPersonalEmail", query = "SELECT e FROM Employees e WHERE e.personalEmail = :personalEmail"),
    @NamedQuery(name = "Employees.findByBusinessEmail", query = "SELECT e FROM Employees e WHERE e.businessEmail like :businessEmail and e.empId <> 1"),
    @NamedQuery(name = "Employees.findByBusinessMail", query = "SELECT e FROM Employees e WHERE e.businessEmail = :businessEmail"),
    @NamedQuery(name = "Employees.findByAddress", query = "SELECT e FROM Employees e WHERE e.address = :address"),
    @NamedQuery(name = "Employees.findByBirthDate", query = "SELECT e FROM Employees e WHERE e.birthDate = :birthDate"),
    @NamedQuery(name = "Employees.findByNationality", query = "SELECT e FROM Employees e WHERE e.nationality = :nationality"),
    @NamedQuery(name = "Employees.findByMaritalStatus", query = "SELECT e FROM Employees e WHERE e.maritalStatus = :maritalStatus"),
    @NamedQuery(name = "Employees.findByGender", query = "SELECT e FROM Employees e WHERE e.gender = :gender"),
    @NamedQuery(name = "Employees.findBySkype", query = "SELECT e FROM Employees e WHERE e.skype = :skype"),
    @NamedQuery(name = "Employees.findByPhoneNumber", query = "SELECT e FROM Employees e WHERE e.phoneNumber = :phoneNumber"),
    @NamedQuery(name = "Employees.findByMobile1", query = "SELECT e FROM Employees e WHERE e.mobile1 = :mobile1"),
    @NamedQuery(name = "Employees.findByMobile2", query = "SELECT e FROM Employees e WHERE e.mobile2 = :mobile2"),
    @NamedQuery(name = "Employees.findBySalary", query = "SELECT e FROM Employees e WHERE e.salary = :salary"),
    @NamedQuery(name = "Employees.findByStartDate", query = "SELECT e FROM Employees e WHERE e.startDate = :startDate"),
    @NamedQuery(name = "Employees.findByKinName", query = "SELECT e FROM Employees e WHERE e.kinName = :kinName"),
    @NamedQuery(name = "Employees.findByKinRelationship", query = "SELECT e FROM Employees e WHERE e.kinRelationship = :kinRelationship"),
    @NamedQuery(name = "Employees.findByKinPhoneNumber", query = "SELECT e FROM Employees e WHERE e.kinPhoneNumber = :kinPhoneNumber"),
    @NamedQuery(name = "Employees.findByKinEmail", query = "SELECT e FROM Employees e WHERE e.kinEmail = :kinEmail"),
    @NamedQuery(name = "Employees.findByStatus", query = "SELECT e FROM Employees e WHERE e.status = :status"),
    @NamedQuery(name = "Employees.findByBusinessEmail&Password", query = "SELECT e FROM Employees e WHERE e.businessEmail = :businessEmail and e.password = :password "),
    @NamedQuery(name = "Employees.findByType", query = "SELECT e FROM Employees e WHERE e.type = :type")})
public class Employees implements Serializable {
    @Column(name =     "birth_date")
    @Temporal(TemporalType.DATE)
    private Date birthDate;
    @Basic(optional =     false)
    @NotNull
    @Column(name = "start_date")
    @Temporal(TemporalType.DATE)
    private Date startDate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "all_holidays")
    private int allHolidays;
    @Basic(optional = false)
    @NotNull
    @Column(name = "used_holidays")
    private int usedHolidays;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "emp_id")
    private Integer empId;
    @Size(max = 45)
    @Column(name = "first_name")
    private String firstName;
    @Size(max = 45)
    @Column(name = "last_name")
    private String lastName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "password")
    private String password;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "personal_email")
    private String personalEmail;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "business_email")
    private String businessEmail;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "address")
    private String address;
    @Size(max = 45)
    @Column(name = "nationality")
    private String nationality;
    @Size(max = 10)
    @Column(name = "marital_status")
    private String maritalStatus;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "gender")
    private String gender;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "skype")
    private String skype;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "phone_number")
    private String phoneNumber;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "mobile1")
    private String mobile1;
    @Size(max = 15)
    @Column(name = "mobile2")
    private String mobile2;
    @Basic(optional = false)
    @NotNull
    @Column(name = "salary")
    private long salary;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "kin_name")
    private String kinName;
    @Size(max = 45)
    @Column(name = "kin_relationship")
    private String kinRelationship;
    @Size(max = 15)
    @Column(name = "kin_phone_number")
    private String kinPhoneNumber;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "kin_email")
    private String kinEmail;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "status")
    private String status;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "type")
    private String type;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "employee")
    private Collection<SourceCode> sourceCodeCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "createdBy")
    private Collection<Projects> projectsCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "emplyee")
    private Collection<TimeLog> timeLogCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "createdBy")
    private Collection<TimeLog> timeLogCollection1;
    @JoinColumn(name = "job_title2", referencedColumnName = "job_title_id")
    @ManyToOne(optional = false)
    private JobsTitles jobTitle2;
    @JoinColumn(name = "job_title1", referencedColumnName = "job_title_id")
    @ManyToOne(optional = false)
    private JobsTitles jobTitle1;
    @JoinColumn(name = "currency", referencedColumnName = "curr_id")
    @ManyToOne(optional = false)
    private Currencies currency;
    @OneToMany(mappedBy = "employee")
    private Collection<Expenses> expensesCollection;
    @OneToMany(mappedBy = "createdBy")
    private Collection<Expenses> expensesCollection1;

    public Employees() {
    }

    public Employees(Integer empId) {
        this.empId = empId;
    }

    public Employees(Integer empId, String password, String personalEmail, String businessEmail, String address, String gender, String skype, String phoneNumber, String mobile1, long salary, Date startDate, String kinName, String kinEmail, String status, String type) {
        this.empId = empId;
        this.password = password;
        this.personalEmail = personalEmail;
        this.businessEmail = businessEmail;
        this.address = address;
        this.gender = gender;
        this.skype = skype;
        this.phoneNumber = phoneNumber;
        this.mobile1 = mobile1;
        this.salary = salary;
        this.startDate = startDate;
        this.kinName = kinName;
        this.kinEmail = kinEmail;
        this.status = status;
        this.type = type;
    }

    public Integer getEmpId() {
        return empId;
    }

    public void setEmpId(Integer empId) {
        this.empId = empId;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPersonalEmail() {
        return personalEmail;
    }

    public void setPersonalEmail(String personalEmail) {
        this.personalEmail = personalEmail;
    }

    public String getBusinessEmail() {
        return businessEmail;
    }

    public void setBusinessEmail(String businessEmail) {
        this.businessEmail = businessEmail;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Date getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(Date birthDate) {
        this.birthDate = birthDate;
    }

    public String getNationality() {
        return nationality;
    }

    public void setNationality(String nationality) {
        this.nationality = nationality;
    }

    public String getMaritalStatus() {
        return maritalStatus;
    }

    public void setMaritalStatus(String maritalStatus) {
        this.maritalStatus = maritalStatus;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getSkype() {
        return skype;
    }

    public void setSkype(String skype) {
        this.skype = skype;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getMobile1() {
        return mobile1;
    }

    public void setMobile1(String mobile1) {
        this.mobile1 = mobile1;
    }

    public String getMobile2() {
        return mobile2;
    }

    public void setMobile2(String mobile2) {
        this.mobile2 = mobile2;
    }

    public long getSalary() {
        return salary;
    }

    public void setSalary(long salary) {
        this.salary = salary;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public String getKinName() {
        return kinName;
    }

    public void setKinName(String kinName) {
        this.kinName = kinName;
    }

    public String getKinRelationship() {
        return kinRelationship;
    }

    public void setKinRelationship(String kinRelationship) {
        this.kinRelationship = kinRelationship;
    }

    public String getKinPhoneNumber() {
        return kinPhoneNumber;
    }

    public void setKinPhoneNumber(String kinPhoneNumber) {
        this.kinPhoneNumber = kinPhoneNumber;
    }

    public String getKinEmail() {
        return kinEmail;
    }

    public void setKinEmail(String kinEmail) {
        this.kinEmail = kinEmail;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @XmlTransient
    public Collection<SourceCode> getSourceCodeCollection() {
        return sourceCodeCollection;
    }

    public void setSourceCodeCollection(Collection<SourceCode> sourceCodeCollection) {
        this.sourceCodeCollection = sourceCodeCollection;
    }

    @XmlTransient
    public Collection<Projects> getProjectsCollection() {
        return projectsCollection;
    }

    public void setProjectsCollection(Collection<Projects> projectsCollection) {
        this.projectsCollection = projectsCollection;
    }

    @XmlTransient
    public Collection<TimeLog> getTimeLogCollection() {
        return timeLogCollection;
    }

    public void setTimeLogCollection(Collection<TimeLog> timeLogCollection) {
        this.timeLogCollection = timeLogCollection;
    }

    @XmlTransient
    public Collection<TimeLog> getTimeLogCollection1() {
        return timeLogCollection1;
    }

    public void setTimeLogCollection1(Collection<TimeLog> timeLogCollection1) {
        this.timeLogCollection1 = timeLogCollection1;
    }

    public JobsTitles getJobTitle2() {
        return jobTitle2;
    }

    public void setJobTitle2(JobsTitles jobTitle2) {
        this.jobTitle2 = jobTitle2;
    }

    public JobsTitles getJobTitle1() {
        return jobTitle1;
    }

    public void setJobTitle1(JobsTitles jobTitle1) {
        this.jobTitle1 = jobTitle1;
    }

    public Currencies getCurrency() {
        return currency;
    }

    public void setCurrency(Currencies currency) {
        this.currency = currency;
    }

    @XmlTransient
    public Collection<Expenses> getExpensesCollection() {
        return expensesCollection;
    }

    public void setExpensesCollection(Collection<Expenses> expensesCollection) {
        this.expensesCollection = expensesCollection;
    }

    @XmlTransient
    public Collection<Expenses> getExpensesCollection1() {
        return expensesCollection1;
    }

    public void setExpensesCollection1(Collection<Expenses> expensesCollection1) {
        this.expensesCollection1 = expensesCollection1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (empId != null ? empId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Employees)) {
            return false;
        }
        Employees other = (Employees) object;
        if ((this.empId == null && other.empId != null) || (this.empId != null && !this.empId.equals(other.empId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pojos.Employees[ empId=" + empId + " ]";
    }

    public int getAllHolidays() {
        return allHolidays;
    }

    public void setAllHolidays(int allHolidays) {
        this.allHolidays = allHolidays;
    }

    public int getUsedHolidays() {
        return usedHolidays;
    }

    public void setUsedHolidays(int usedHolidays) {
        this.usedHolidays = usedHolidays;
    }
}
